#/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/11 14:46
# @Author  : wyy
# @Email   : 1915059545@qq.com
# @File    : page_sj_home.py
# @Software: PyCharm
"""商机主页"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
class PageSjHome:
    # 点击商机按钮
    shangji_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[1]/li[3]/a')
    # 推进商机按钮
    tuijin_locator = (By.LINK_TEXT, "推进")
    # 末页按钮
    moye_locator = (By.LINK_TEXT, '末页')
    # 删除按钮
    sc_locator = (By.ID, "delete")
    # 进入商机详情页
    sjxqy_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[1]/td[12]/a[1]')
    # 添加商机按钮
    tianjiashangji_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div/a')
    # 前进到阶段下拉框
    xialakuang_locator = (
    By.CSS_SELECTOR, "#dialog-advance > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > select")
    # 下次联系时间
    xiacilianxishijian_locator = (By.CSS_SELECTOR, "#nextstep_time")
    # 联系内容
    neirong_locator = (By.CSS_SELECTOR, "#nextstep")
    # 阶段描述
    miaoshu_locator = (By.XPATH, '//*[@id="dialog-advance"]/form/table/tbody/tr[4]/td[2]/textarea')
    # 推进里面的推进
    tuijin_tuiijn_locator = (By.CSS_SELECTOR,
                             "#dialog-advance > form > table > tbody > tr:nth-child(5) > td:nth-child(2) > input.btn.btn-primary")
    def __init__(self,driver):
        self.driver=driver
    #点击商机按钮进入商机主页
    def click_shangji(self):
        self.driver.find_element(*self.shangji_locator).click()
    #点击推进按钮，进入推进页面
    def click_tuijin(self):
        self.driver.find_element(*self.tuijin_locator).click()
    #完成推进信息
    def input_tuijin(self,index):
        xialakuang_element = self.driver.find_element(*self.xialakuang_locator)
        xialakuang_select = Select(xialakuang_element)
        xialakuang_select.select_by_index(index)
    #输入下次联系时间
    def input_xclxtome(self,xclxtime):
        self.driver.find_element(*self.xiacilianxishijian_locator).send_keys(xclxtime)
    #输入下次联系内容
    def input_neirong(self,neirong):
        self.driver.find_element(*self.neirong_locator).send_keys(neirong)
    #输入阶段描述
    def input_miaoshu(self,miaoshu):
        self.driver.find_element(*self.miaoshu_locator).send_keys(miaoshu)
    #点击【推进】
    def click_tj(self):
        self.driver.find_element(*self.tuijin_tuiijn_locator).click()


    #点击删除
    def click_shanchu(self):
        self.driver.find_element(*self.sc_locator).click()
    #点击查看,进入商机详情页
    def click_sjxq(self):
        self.driver.find_element(*self.sjxqy_locator).click()
    #点击末页
    def click_moye(self):
        self.driver.find_element(*self.moye_locator).click()
